/* 
 * Copyright 2011 kOSMik.
 * This file is part of kOSMik.
 * 
 * kOSMik is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * kOSMik is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with kOSMik.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * kOSMik:
 * Open Street Map - Editor.
 * http://code.google.com/p/swp-dv-ws2010-osm-2/
 */

package de.fuberlin.kosmik.files;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Abstraction layer for the SD-card file system.
 */
public interface FileManager {

	/**
	 * Create a file with the given name in the folder of the current track.
	 * 
	 * @param filename one wishes to use.
	 * @return File descriptor.
	 */
	File putFile(String filename);

	/**
	 * Get the absolute path to the current base directory of current the track.
	 * 
	 * @return absolute path of the base directory for the given track without a
	 *         trailing slash.
	 */
	String getAbsoluteBasePath();

	/**
	 * Return the next unused filename within the given path.
	 * 
	 * @param basename base name of the file.
	 * @return Filename without extension (suffix)
	 */
	String getFilename(String basename);

	/**
	 * Get an OutputStream to the given file within the current track. In case
	 * the there exists no file with the given filename, a new file will be
	 * created.
	 * 
	 * @param filename the name of the file one wishes to access / create.
	 * @return the output stream.
	 * @throws IOException in case media (SD-card) is not ready.
	 */
	OutputStream getStream(String filename) throws IOException;

}
